package com.da.javatest.leetCode;

import java.util.Arrays;
import java.util.Collections;

/**
 * @author chenlida
 * @date 2019/1/8 15:37
 * @description
 */
public class Code215 {
    public static void main(String[] args) {
        System.out.println(new Code215().findKthLargest(new int[] {3, 2, 3, 1, 2, 4, 5, 5, 6}, 4));
    }

    public int findKthLargest(int[] nums, int k) {
        Arrays.sort(nums);
        int count = 1;
        for (int i = nums.length - 1; i >= 0; i--) {
            if (k == count) {
                return nums[i];
            } else {
                count++;
            }
        }

        return -1;
    }
}
